﻿using GestorSQL.CaseFlowIntegration.Interface;
using GestorSQL.Utility;
using GestorSQL.Security.Interface;
using GestorSQL.DAO.FileManager;
using GestorSQL.DataBase.Interface;
using GestorSQL.DAO;
using GestorSQL.BusinessEntities;

namespace GestorSQL.BLL.ImplementationsBridge
{
    public class ImplementationBridge
    {
        public static ICaseFlowTool GetCaseFlowImplementation()
        {
            return TypeExtensionMethods.GetInstance<ICaseFlowTool>(null,
                "SharedAssembliesPath".CombinePathFromAppCfg("CaseFlowImplementationDll"),
                "CaseFlowImplementationClass".GetFromAppCfg());
        }

        public static IUserManager GetUserManagerImplementation()
        {
            return TypeExtensionMethods.GetInstance<IUserManager>(null,
                    "SharedAssembliesPath".CombinePathFromAppCfg("SecurityImplementationDll"),
                    "SecurityImplementationClass".GetFromAppCfg());
        }

        public static IFileManager GetFileManager(string type)
        {
            if(type.Equals("Text"))
                return new TextFile();
            else
                return new  CompressFile();
                
        }

        public static IDataBaseProvider GetDataBaseImplementationByCore(int coreId)
        {
            GestorSqlDao dao = new GestorSqlDao();
            Core core = dao.GetCoreById(coreId);
            return TypeExtensionMethods.GetInstance<IDataBaseProvider>(null,
                    "SharedAssembliesPath".GetFromAppCfg().CombinePath(core.Assembly),
                    core.Class);
        }
    }
}
